import React, { useEffect, useRef } from 'react'
// 自定义hook防抖
function Mylodash(fun, time) {
    let jsq = useRef()
    useEffect(() => {
        return () => {
            if (jsq.current) {
                clearTimeout(jsq.current)
            }
        }
    }, [])
    return (...val) => {
        if (jsq.current) {
            clearTimeout(jsq.current)
        }

        setTimeout(() => {
            return fun(...val)
        }, time)

    }
}

export default Mylodash
